#include<iostream>
using namespace std;
#include<vector>
int main(){
    int n;
    cin >> n;
    vector<int> arr(n+1);
    for (int i = 1; i <= n;i++){
        scanf("%d", &arr[i]);
    }
    vector<int> s(n);
    for (int i = 1; i < n+1;i++){
        s[i] = s[i - 1] + arr[i];
    }
    int m, l, r;
    cin >> m;
    int k = m;
    vector<int> num(m);
    while(m>0){
        scanf("%d%d", &l, &r);
        num[m] = s[r] - s[l - 1];
        m--;
    }
    for (int i = k; i > 0; i--)
    {
        cout << num[i] << endl;
    }
    return 0;
}